package yf.mall.vo.up;


import lombok.Data;

import java.util.Date;

import com.alibaba.excel.annotation.*;

import java.io.Serializable;



import yf.mall.entity.ArticleEntity;
import yf.mall.vo.ArticleVo;

                                        import yf.mall.enums.ArticleStatusEnum;
            import yf.mall.enums.ArticleTypeEnum;
        
/**
 * 文章实体
 * 表名 article
 *
 *
 *
 * @date Wed Aug 02 10:54:31 CST 2023
 */
@Data
public class ArticleUp implements Serializable {
    @ExcelIgnore
    private static final long serialVersionUID = 1L;

                        //新闻ID
            @ExcelProperty("新闻ID")
            private Long id;
        
                        //标题
            @ExcelProperty("标题")
            private String title;
        
                        //IMG-封面
            @ExcelProperty("IMG-封面")
            private String img;
        
                        //IMG-详情
            @ExcelProperty("IMG-详情")
            private String bigImg;
        
                        //作者名
            @ExcelProperty("作者名")
            private String author;
        
                        //内容
            @ExcelProperty("内容")
            private String body;
        
                        //阅读数量
            @ExcelProperty("阅读数量")
            private Long readCount;
        
                        //发表时间
            @ExcelProperty("发表时间")
            private Date date;
        
                        //ENUM-状态:"PUBLISH-发表","NEW-未发表"
            @ExcelIgnore
            private Integer status;
                        @ExcelProperty("状态")
            private String statusStr;
        
                        //ENUM-类型:"MAN-名人堂","COLLEGE-爆单学院","BRAND-品牌介绍","OTHER-其他"
            @ExcelIgnore
            private Integer type;
                        @ExcelProperty("类型")
            private String typeStr;
        
                        //排序
            @ExcelProperty("排序")
            private Integer sort;
        
    
    public ArticleUp() {

    }

    public ArticleVo toVo() {

        ArticleEntity entity = new ArticleEntity();
            ArticleVo vo = new ArticleVo(entity);
                                    entity.setId(id);
            
                                    entity.setTitle(title);
            
                                    entity.setImg(img);
            
                                    entity.setBigImg(bigImg);
            
                                    entity.setAuthor(author);
            
                                    entity.setBody(body);
            
                                    entity.setReadCount(readCount);
            
                                    entity.setDate(date);
            
                                    if (getStatusStr() != null) {
                    entity.setStatus(ArticleStatusEnum.nameOf(getStatusStr()));
                }
            
                                    if (getTypeStr() != null) {
                    entity.setType(ArticleTypeEnum.nameOf(getTypeStr()));
                }
            
                                    entity.setSort(sort);
            
        
        return  vo;
    }



}
